<html>
<head><meta charset="utf-8"><title>Internal compiler error using lang items · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html">Internal compiler error using lang items</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="219142157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219142157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan Dönszelmann <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219142157">(Dec 07 2020 at 21:40)</a>:</h4>
<p>While working on a project I ran into an internal compiler error related to lang items. I made an issue about it, and started digging into the compiler internals to find out what was actually happening. I added a comment to the issue explaining what I think is going on: I believe it has to do with the entrypoint for monomorphization. Rust may use the #[lang=start] function as an entrypoint, even if this function sits in a foreign crate and may never be an entrypoint for monomorphization. </p>
<p>This is the first time I'm looking at the rust source code so I may be completely wrong about this. The issue related to this topic is: <a href="https://github.com/rust-lang/rust/issues/79559">https://github.com/rust-lang/rust/issues/79559</a>.</p>



<a name="219144596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219144596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219144596">(Dec 07 2020 at 22:01)</a>:</h4>
<p>It looks like a MIR is not exported. I think, the difference between start in std is that it is generic.</p>



<a name="219145520"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219145520" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan Dönszelmann <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219145520">(Dec 07 2020 at 22:08)</a>:</h4>
<p>You are right. Whenever I make lang_start() generic in any way (just make main return some T: 'static) it works; kinda. It produces a linking error. Still not the desired behavior but at least no ICE</p>



<a name="219145800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219145800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tm <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219145800">(Dec 07 2020 at 22:11)</a>:</h4>
<p>the <code>#[no_mangle]</code> on <code>lang_start</code> also doesn't seem right</p>



<a name="219146138"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219146138" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan Dönszelmann <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219146138">(Dec 07 2020 at 22:12)</a>:</h4>
<p>Hmm, that may be right but doesn't seem to make a difference. No ICE but still a linking error</p>



<a name="219146210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Internal%20compiler%20error%20using%20lang%20items/near/219146210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonathan Dönszelmann <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Internal.20compiler.20error.20using.20lang.20items.html#219146210">(Dec 07 2020 at 22:13)</a>:</h4>
<p>I attached the linking error to the github issue</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>